// $(document).ready(function () {

    $("#jqGrid").jqGrid({
        url: select_url + 'user',
        editurl: edit_url + 'user',
        mtype: 'POST',
        datatype: "json",
        colModel: [
            {
                label: '账号',
                name: 'id',
                width: 100,
                key: true,
                editable: true,
                editrules : { required: true},
                readonly:true
            },
            {
                label: '密码',
                name: 'pass',
                width: 120,
                editable: true,
                edittype: 'password',
                formatter: 'password',
                // hidden: true,
                // editrules:{
                //     // edithidden:true, //密码在加载数据时不显示，编辑时显示??
                //     required: true
                // },
                // editoptions: {size:10, maxlength: 8},
                // formatter:function(cellvalue, options, rowObject){
                //     console.log(md5(1111)); //md5 加密存入数据库？？
                //     return md5(cellvalue);
                // }
                 formoptions:{}
            },
            {
                label : '用户名',
                name: 'name',
                width: 150,
                editable: true,
                // formoptions:{
                //     elmsuffix:"<span class='red' style='float:right;'>*</span>"
                // }
            },
            {
                label : '电话号码',
                name: 'tele',
                width: 150,
                editable: true
            },
            {
                label: '客户名称',
                name: 'clientname',
                width: 100,
                editable: true
            },
            {
                label : '是否启用',
                name: 'use',
                width: 100,
                editable: true,
                edittype:'select',formatter:'select',
                editoptions : {
                    value:"1 : 启用; 0 : 禁止"
                }
            },
            {
                label : '到期时间',
                name: 'timeto',
                width: 180,
                editable: true,
                fixed: true, formatter: 'date',
                formatoptions: {srcformat:'Y-m-d H:i:s',newformat:'Y-m-d H:i:s'},
            },
            {
                label: '角色',
                name: 'roleid',
                width: 150,
                editable: true,
                edittype:'select',formatter : 'select',
                editoptions : {
                    value:"0 : 普通用户; 1 : 管理员; 2 : 超级管理员"
                }
            },
            {
                label: '头像',
                name: 'pic',
                width: 120,
                editable: false,
                text:"默认头像",
                // edittype:'file'
                edittype:'select',formatter : 'select',
                editoptions : {
                    value:"null: 默认头像",
                    // text:"默认头像"
                }
            },
            {//行编辑
                label: "操作",
                name: "actions",
                width: 100,
                formatter: "actions",
                formatoptions: {
                    keys: true,
                    editOptions: {},
                    addOptions: {},
                    delOptions: {}
                }       
            }
        ],

        jsonReader: {
            root: 'rows',
            repeatitems : false,
            id: "0"
        },
        rowNum:10,
        rowList:[10,20,30],
        sortname: 'id',
        sortorder : 'desc',//倒序
        viewrecords: true,
        // styleUI : 'jQueryUI',
        rownumbers: true, //行序号
        rownumWidth: 25,
        multiselect: true,//复选框
        // width: 1000,
        width: ($('#FootableClose .body-nest').css('width'))-100,
        height: 350,
        pager: "#jqGridPager",
        shrinkToFit: false
    });


    var template = "<div style='margin-left:15px;'><div> 账号 <sup>*</sup>:</div><div>{id} </div>";
    template += "<div> 密码: </div><div>{pass} </div>";
    template += "<div> 用户名:</div><div> {name} </div>";
    template += "<div> 电话号码: </div><div>{tele} </div>";
    template += "<div> 是否启用: </div><div>{use} </div>";
    template += "<div> 到期时间: </div><div>{timeto} </div>";
    template += "<div> 角色:</div><div> {roleid} </div>";
    template += "<div> 头像:</div><div> {pic} </div>";
    template += "<hr style='width:100%;'/>";
    template += "<div> {sData} {cData}  </div></div>";

    

    $('#jqGrid').navGrid('#jqGridPager',
        // the buttons to appear on the toolbar of the grid
        { edit: true, add: true, del: true, search: false, refresh: true, view: false, position: "left", cloneToTop: false },
        // Edit Dialog
        {
            editCaption: "修改用户信息",
        },
        // Add Dialog
        {
            addCaption: "添加用户信息",
        }
    );

    //查询
    var account_mask = $("#s_account").val();
    var name_mask = $("#s_name").val();
    var client_mask = $("#s_clientname").val();
    gridReload("user?id="+account_mask+"&name="+name_mask+"&clientname="+client_mask);

    
// });